Rotating an image by 90, 180, or 270 degrees with respect to its original orientation is a common operation for data processing systems, including printers, computers, digital cameras, mobile telephones with image capabilities, personal digital assistants (PDAs), and other image processing systems. Typically, pixels are read into a data processing system in a first orientation (for example, a horizontal orientation), and the pixels are written out of the data processor in a second orientation (for example, a vertical orientation).
In many cases, a digital image to be rotated is stored in a memory that is accessible to an image processor, and the desired output of an image rotation process performed by the image processor is a rotated digital image that is stored in the same memory. A process of rotating the digital image may include copying pixels from a source image location within the memory to a destination image location within the memory in a manner that achieves the desired rotation. Thus, the speed with which the rotated image can be created depends on the speed with which pixels can be read from the source image and written to the destination image.
One approach to creating the rotated destination image includes copying pixels from the source image to the destination image, one pixel at a time. In this pixel-by-pixel rotation process, the image processor reads a pixel from the source image and writes the pixel to the appropriate location within the destination image. The image processor may iteratively perform the read and write operations until each pixel of the source image has been written to the destination image. An advantage of this approach is that a memory associated with the image processor can be sized to store only a single pixel of the source image. However, by reading and writing one pixel at a time, such an approach does not take advantage of memory efficiencies associated with reading or writing consecutive address locations.
Images are typically stored in memory in a particular arrangement of data bits, which places horizontally adjacent pixel data associated with the image in consecutive address locations within the memory. A rotation technique can obtain improved memory access efficiencies by reading and writing groups of adjacent pixels within the same image row using consecutive memory addresses, rather than accessing non-adjacent memory locations.
For example, a particular rotation technique for a 90-degree clockwise rotation may read a group of 16 horizontally adjacent pixels from a row of the source image and write the pixels to appropriate locations in the destination image. The read operation may be performed efficiently to access adjacent memory locations; however, the pixels are rotated into vertically adjacent locations in the destination image. Writing pixel data to the vertically adjacent locations in the destination image uses 16 separate write operations to non-consecutive locations. While this technique is more efficient than the pixel-by-pixel rotation process, the 16-pixel technique uses more memory space within the image processor.
In general, the term cache line may be used to represent a set of consecutive memory reads or writes which can be grouped together to obtain efficient memory access. There is a tradeoff between efficiency in terms of memory accesses used to rotate an image and the amount of memory within the image processor that can be used to store the pixels that are being rotated. Hence, there is a need for improved image rotation methods and systems.